Fix implicitly-deleted default constructor error on older Xcode versions#8719
Merged
Conversation
Member
Author
|
@tlively I'm afraid to say Gemini came up with move 90% of this, but it seems reasonable. I don't have any easy way to test on the older Xcode though. |
85067d1 to
d3283c8
Compare
tlively
approved these changes
May 18, 2026
f17e271 to
6d8cc57
Compare
Older versions of Clang (particularly those shipped with older Xcode versions) are more strict about the initialization of const members. According to the C++ standard, if a class has a const member that is not initialized at the point of declaration and lacks a user-provided default constructor that initializes it, the default constructor is implicitly deleted. While newer versions of Clang and other compilers may allow this if the member has a trivial default constructor (like our View struct, which has an inline initializer for its only member), older versions of Apple Clang have been known to reject this, leading to build failures when inheriting from IString (e.g., in the Name class). This change provides an explicit default constructor for IString that initializes the 'str' member, ensuring compatibility across a wider range of compiler versions.
6d8cc57 to
38dc263
Compare
sbc100
added a commit
that referenced
this pull request
May 18, 2026
In emsdk we actually build on macos-13, but sadly there is not macos-13
available in github actions.
In doing this I'm trying to get binaryen CI to reproduce the current
issue we are seeing in emsdk CI:
```
In file included from /Users/distiller/project/binaryen/main/src/ir/import-names.h:23:
/Users/distiller/project/binaryen/main/src/support/name.h:35:12: error: call to implicitly-deleted default constructor of 'wasm::IString'
Name() : IString() {}
^
/Users/distiller/project/binaryen/main/src/support/istring.h:72:3: note: explicitly defaulted function was implicitly deleted here
IString() = default;
^
/Users/distiller/project/binaryen/main/src/support/istring.h:68:14: note: default constructor of 'IString' is implicitly deleted because field 'str' of const-qualified type 'const wasm::IString::View' would not be initialized
const View str;
^
```
Split out from #8719
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Older versions of Clang (particularly those shipped with older Xcode versions) are more strict about the initialization of const members. According to the C++ standard, if a class has a const member that is not initialized at the point of declaration and lacks a user-provided default constructor that initializes it, the default constructor is implicitly deleted.
While newer versions of Clang and other compilers may allow this if the member has a trivial default constructor (like our View struct, which has an inline initializer for its only member), older versions of Apple Clang have been known to reject this, leading to build failures when inheriting from IString (e.g., in the Name class).
This change provides an explicit default constructor for IString that initializes the 'str' member, ensuring compatibility across a wider range of compiler versions.